package com.db.functions;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

import java.text.SimpleDateFormat;
import java.util.Calendar;


public abstract class SystemTime {
    
    private static Calendar calendar; 
    private static SimpleDateFormat dateFormat; 
    private static SimpleDateFormat timeFormat; 
    private static String currentDate; 
    private static String currentTime;
    
    
    //Get the current system Time
    public static String getCurrentTime(){
        calendar = Calendar.getInstance();
        timeFormat = new SimpleDateFormat("h:mm:ss a");
        currentTime = timeFormat.format(calendar.getTime());
        return currentTime;
        
    }
    
    
    
    //Get the current system date
    public static String getCurrentDate(){
        calendar = Calendar.getInstance();
        dateFormat = new SimpleDateFormat("EEEEEEEEEE, MMMMMMMMM dd yyyy");
        try{
            currentDate = dateFormat.format(calendar.getTime());
        }
        catch(Exception ex){
            currentDate = dateFormat.format(calendar.getTime());
        }   
        return currentDate;
        
    }
    
   
    
    public static String getCurrentTimeForMessage(){
        calendar = Calendar.getInstance();
        timeFormat = new SimpleDateFormat("H");
        currentTime = timeFormat.format(calendar.getTime());
        return currentTime;
    }
    
    public static String getWelcomeMessage(){
        int time = Integer.parseInt(SystemTime.getCurrentTimeForMessage());
        String result = "";
        if(time>=0 && time <4){
        	result+= "Good Midnight! ";
        }
        else if(time>=4 && time<12){
        	result+=  "Good Morning! ";
        }
        else if(time>=12 && time<18){
        	result+=  "Good Afternoon! ";
        }
        else{
        	result+=  "Good Evening! ";
        }
        result+= "Today is "+getCurrentDate()+", "+getCurrentTime()+". ";
        return result;
    }
    
    
    
    @SuppressWarnings("CallToThreadDumpStack")
    public static void sleep(int n){
        try{
            Thread.sleep(n);
        }catch(Exception ex){
            ex.printStackTrace();
        }
    }
}
